﻿using AutoUpdateMgr.Mgr;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AutoUpdateMgr
{
    public partial class FormCreateVersion : Form
    {
        public FormCreateVersion()
        {
            InitializeComponent();
        }

        public Action<AutoUpdate.Model.Packet.Packet> callback = null;
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtVersion.Text.Trim()))
            {
                MessageBox.Show("请输入版本号");

                return;
            }

            AutoUpdate.Model.Packet.RequestPacket request = new AutoUpdate.Model.Packet.RequestPacket();

            request.CommandText = "createVersion";

            ActionMgr.getInstance().addAction(request.PacketID, this.callback);

            AutoUpdate.Model.Model.fileTransfer.fs_version versionModel = new AutoUpdate.Model.Model.fileTransfer.fs_version();

            versionModel.version = this.txtVersion.Text.Trim();

            versionModel.createTime = AutoUpdate.Utility.Helper.TimeUtils.CurrentTime();

            request.MessageContent = AutoUpdate.Utility.Helper.JsonHelper.getString(versionModel);

            ClientMgr.getInstance().client.sendMessage(AutoUpdate.Utility.Helper.JsonHelper.getString(request));

            this.Close();
        }

        private void FormCreateVersion_Load(object sender, EventArgs e)
        {

        }
    }
}
